#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}


string s;

inline void solution() {
    getline(cin, s);

    // 特判
    if (s.size() < 3) {
        if (s.size() == 1) cout << 1 << endl;
        else if (s.size() == 2 ) cout << (s[0] == s[1] ? 2 : 1) << endl;
        return ;
    } 
    
    int res = 1;
    // ABCBA
    for (int i = 0, j = i + 2; i < s.size() - 2; i ++, j ++) {
        if (s[i] == s[j]) {
            int l = i, r = j;
            while (l >= 0 && r < s.size() && s[l] == s[r]) {
                l -- ;
                r ++ ;
            }
            res = max(res, r - l - 1);
        }
    }

    // ABBA
    for (int i = 0, j = i + 1; i < s.size() - 1; i ++ , j ++ ) {
        if (s[i] == s[j]) {
            int l = i, r = j;
            while (l >= 0 && r < s.size() && s[l] == s[r]) {
                l -- ;
                r ++ ;
            }
            res = max(res, r - l - 1);
        }
    }

    cout << res << endl;
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}